﻿package mortal.game.view.copy.QuestionCopy.item
{
    import com.gengine.global.*;
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class QuestionCopyCountDownPanel extends View
    {
        protected var _bg:GBitmap;
        protected var _text:GTextFiled;
        private var _isUILoad:Boolean = false;
        private static var _instance:QuestionCopyCountDownPanel;

        public function QuestionCopyCountDownPanel()
        {
            this.layer = LayerManager.uiLayer;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            LoaderHelp.addResCallBack(ResFileConst.questionCopy, this.onShowHd);
            return;
        }// end function

        private function onShowHd() : void
        {
            this._isUILoad = true;
            this._bg = UIFactory.gBitmap(ImagesConst.QuestionCopyCountDownBg, 0, 0, this);
            this._text = UIFactory.gTextField("" + Language.getString(70947), 0, 8, 394, 30, this, GlobalStyle.textFormatHuang2.setSize(18).center());
            this._text.mouseEnabled = false;
            this.stageResize();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._isUILoad = false;
            this._bg.dispose(param1);
            this._text.dispose(param1);
            this._bg = null;
            this._text = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function showCountDown(param1:int) : void
        {
            if (this._isUILoad == false)
            {
                return;
            }
            param1 = param1 < 0 ? (0) : (param1);
            var _loc_2:* = int(param1 / 60);
            var _loc_3:* = param1 % 60;
            var _loc_4:* = _loc_3 < 10 ? ("0" + _loc_3) : ("" + _loc_3);
            this._text.text = Language.getStringByParam(70948, _loc_2, _loc_4);
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show(param1, param2);
            this.stageResize();
            return;
        }// end function

        override public function stageResize() : void
        {
            super.stageResize();
            x = Global.stage.stageWidth - this.width >> 1;
            y = Global.stage.stageHeight - this.height >> 1;
            return;
        }// end function

        public static function get instance() : QuestionCopyCountDownPanel
        {
            if (_instance == null)
            {
                _instance = new QuestionCopyCountDownPanel;
            }
            return _instance;
        }// end function

    }
}
